/*
 * 找出两个数组的交集
 */
package charles.testproject.findarraysintersetion;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.Vector;

public class FindArraysIntersetion {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Vector<Integer> storage = new Vector();
		int[] arr1 = {1,3,5,7,9,10};
		int[] arr2 = {1,2,3,5,8,9};
		for(int i =0,j=0;;){
			if(i > arr1.length - 1||j>arr2.length -1){
				break;
			}
			if(arr1[i] > arr2[j]) {
				j++;
			}else if(arr1[i] < arr2[j]) {
				i++;
			}else if(arr1[i] == arr2[j]){
				System.out.println(arr1[i]);
				storage.add(arr1[i]);
				i++;
				j++;
			}
		}
		System.out.println("*********Call over Vector by "+"enumeration"+"**********");
		Iterator it = storage.iterator();
		Enumeration e = storage.elements();
		while(e.hasMoreElements()) {
			System.out.println(e.nextElement().toString());
		}
		System.out.println("*********Call over Vector by "+"int i"+"**********");
		for(int i = 0; i < storage.size();i++) {
			System.out.println(storage.get(i));
		}
	}

}
